#coding=utf-8
from django.db import models

# Create your models here.
class YiSheng(models.Model):
    YongHuMing = models.CharField('用户名',max_length=50)
    MiMa = models.CharField('密码',max_length=50)    
    XingMing = models.CharField('姓名',max_length=50)
    XingBie = models.CharField('性别',max_length=5)
    LianXiDianHua = models.CharField('联系电话',max_length=11,null=True,blank=True)
    JianJie = models.TextField('简介',null=True,blank=True)
    timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
    updated = models.DateTimeField(auto_now_add=False, auto_now=True)
    
    class Meta():
        verbose_name = '医生'
        verbose_name_plural = '医生'
    
    def __unicode__(self):
        return unicode(self.XingMing)
    

    
    
class YongHu(models.Model):
    YongHuMing = models.CharField('用户名',max_length=50)
    MiMa = models.CharField('密码',max_length=50)
    XingMing = models.CharField('姓名',max_length=30,null=True,blank=True)
    XingBie = models.CharField('性别',max_length=5,null=True,blank=True)
    NianLing = models.IntegerField('年龄',null=True,blank=True)
    JiuZhenRiQi = models.DateField('就诊日期',null=True,blank=True)
    ZhuZhi = models.CharField('住址',max_length=100,null=True,blank=True)
    LianXiDianHua = models.CharField('联系电话',max_length=11,null=True,blank=True)
    BeiZhu = models.TextField('备注',null=True,blank=True)
    ZhuZhiYiSheng = models.ManyToManyField(YiSheng,verbose_name = '主治医生')
    timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
    updated = models.DateTimeField(auto_now_add=False, auto_now=True)
    
    
    class Meta():
        verbose_name = '用户'
        verbose_name_plural = '用户'
    
    def __unicode__(self):
        return unicode(self.YongHuMing)
    

     
    
class YanShouRen(models.Model):
    XingMing = models.CharField('姓名',max_length=50)
    LianXiDianHua = models.CharField('联系电话',max_length=11)
    timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
    updated = models.DateTimeField(auto_now_add=False, auto_now=True)
    class Meta():
        verbose_name = '验收人'
        verbose_name_plural = '验收人'
    
    def __unicode__(self):
        return unicode(self.XingMing)
    

  
class ShengChanQiYe(models.Model):
    QiYeMing = models.CharField('企业名',max_length=100)
    LianXiDianHua = models.CharField('联系电话',max_length=11)
    DiZhi = models.CharField('地址',max_length=100)
    timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
    updated = models.DateTimeField(auto_now_add=False, auto_now=True)
    class Meta():
        verbose_name = '生产企业'
        verbose_name_plural = '生产企业'
    
    def __unicode__(self):
        return unicode(self.QiYeMing)
     

    
    
class GongHuoQiYe(models.Model):
    QiYeMing = models.CharField('企业名',max_length=100)
    LianXiDianHua = models.CharField('联系电话',max_length=11)
    DiZhi = models.CharField('地址',max_length=100)
    timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
    updated = models.DateTimeField(auto_now_add=False, auto_now=True)
    class Meta():
        verbose_name = '供货企业'
        verbose_name_plural = '供货企业'
    
    def __unicode__(self):
        return unicode(self.QiYeMing)
     


 
class YaoPin(models.Model):
    TongYongMing = models.CharField('通用名',max_length=100)
    ShangPinMing = models.CharField('商品名',max_length=100)
    JiXing = models.CharField('剂型',max_length=50)
    GuiGe = models.CharField('规格',max_length=20)
    ZhiLiangZhuangKuang = models.CharField('质量状况',max_length=20)
    KuCunShengYu = models.CharField('库存剩余量',max_length=20)
    PiZhunWenHao = models.CharField('批准文号',max_length=100)
    PiHao = models.CharField('批号',max_length=100)
    YouXiaoQiZhi = models.DateField('药效起止')
    YanShouJieLun = models.CharField('验收结论',max_length=50)
    BeiZhu = models.TextField('备注')
    YanShouRen = models.ForeignKey(YanShouRen,verbose_name = '验收人' )
    ShengChanQiYe = models.ManyToManyField(ShengChanQiYe,verbose_name = '生产企业')
    GongHuoQiYe = models.ManyToManyField(GongHuoQiYe,verbose_name = '供货企业')
    timestamp = models.DateTimeField(auto_now_add=True, auto_now=False)
    updated = models.DateTimeField(auto_now_add=False, auto_now=True)
    class Meta():
        verbose_name = '药品'
        verbose_name_plural = '药品'
    
    def __unicode__(self):
        return unicode(self.TongYongMing)
     
